package com.javalab.springmvc.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import com.javalab.springmvc.service.HelloService;

@Controller
@RequestMapping("/welcome")
public class HelloController {

	@Autowired
	private HelloService service;

	@RequestMapping(method = RequestMethod.GET)
	public String printWelcome(
			@RequestParam(value = "name", required = false, defaultValue = "World") String name,
			ModelMap model) {
		service.sayHello();
		model.addAttribute("message", name);
		return "hello";

	}

}
